/**
 */
package de.thwildau.tm.moses.thrift.thrift.impl;

import de.thwildau.tm.moses.thrift.thrift.Annotation;
import de.thwildau.tm.moses.thrift.thrift.FieldType;
import de.thwildau.tm.moses.thrift.thrift.SetType;
import de.thwildau.tm.moses.thrift.thrift.ThriftPackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Set Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.thwildau.tm.moses.thrift.thrift.impl.SetTypeImpl#getSetType <em>Set Type</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.thrift.thrift.impl.SetTypeImpl#getSetTypeAnnotation <em>Set Type Annotation</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SetTypeImpl extends ContainerTypeImpl implements SetType
{
  /**
   * The cached value of the '{@link #getSetType() <em>Set Type</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSetType()
   * @generated
   * @ordered
   */
  protected FieldType setType;

  /**
   * The cached value of the '{@link #getSetTypeAnnotation() <em>Set Type Annotation</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSetTypeAnnotation()
   * @generated
   * @ordered
   */
  protected Annotation setTypeAnnotation;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected SetTypeImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return ThriftPackage.Literals.SET_TYPE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public FieldType getSetType()
  {
    return setType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetSetType(FieldType newSetType, NotificationChain msgs)
  {
    FieldType oldSetType = setType;
    setType = newSetType;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ThriftPackage.SET_TYPE__SET_TYPE, oldSetType, newSetType);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSetType(FieldType newSetType)
  {
    if (newSetType != setType)
    {
      NotificationChain msgs = null;
      if (setType != null)
        msgs = ((InternalEObject)setType).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ThriftPackage.SET_TYPE__SET_TYPE, null, msgs);
      if (newSetType != null)
        msgs = ((InternalEObject)newSetType).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ThriftPackage.SET_TYPE__SET_TYPE, null, msgs);
      msgs = basicSetSetType(newSetType, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ThriftPackage.SET_TYPE__SET_TYPE, newSetType, newSetType));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Annotation getSetTypeAnnotation()
  {
    return setTypeAnnotation;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetSetTypeAnnotation(Annotation newSetTypeAnnotation, NotificationChain msgs)
  {
    Annotation oldSetTypeAnnotation = setTypeAnnotation;
    setTypeAnnotation = newSetTypeAnnotation;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ThriftPackage.SET_TYPE__SET_TYPE_ANNOTATION, oldSetTypeAnnotation, newSetTypeAnnotation);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSetTypeAnnotation(Annotation newSetTypeAnnotation)
  {
    if (newSetTypeAnnotation != setTypeAnnotation)
    {
      NotificationChain msgs = null;
      if (setTypeAnnotation != null)
        msgs = ((InternalEObject)setTypeAnnotation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ThriftPackage.SET_TYPE__SET_TYPE_ANNOTATION, null, msgs);
      if (newSetTypeAnnotation != null)
        msgs = ((InternalEObject)newSetTypeAnnotation).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ThriftPackage.SET_TYPE__SET_TYPE_ANNOTATION, null, msgs);
      msgs = basicSetSetTypeAnnotation(newSetTypeAnnotation, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ThriftPackage.SET_TYPE__SET_TYPE_ANNOTATION, newSetTypeAnnotation, newSetTypeAnnotation));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case ThriftPackage.SET_TYPE__SET_TYPE:
        return basicSetSetType(null, msgs);
      case ThriftPackage.SET_TYPE__SET_TYPE_ANNOTATION:
        return basicSetSetTypeAnnotation(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case ThriftPackage.SET_TYPE__SET_TYPE:
        return getSetType();
      case ThriftPackage.SET_TYPE__SET_TYPE_ANNOTATION:
        return getSetTypeAnnotation();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case ThriftPackage.SET_TYPE__SET_TYPE:
        setSetType((FieldType)newValue);
        return;
      case ThriftPackage.SET_TYPE__SET_TYPE_ANNOTATION:
        setSetTypeAnnotation((Annotation)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case ThriftPackage.SET_TYPE__SET_TYPE:
        setSetType((FieldType)null);
        return;
      case ThriftPackage.SET_TYPE__SET_TYPE_ANNOTATION:
        setSetTypeAnnotation((Annotation)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case ThriftPackage.SET_TYPE__SET_TYPE:
        return setType != null;
      case ThriftPackage.SET_TYPE__SET_TYPE_ANNOTATION:
        return setTypeAnnotation != null;
    }
    return super.eIsSet(featureID);
  }

} //SetTypeImpl
